<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<%-- CSS Style Declarations --%>
	<link rel ="stylesheet" type="text/css" href="stylesheets/style.css" ></link>

	<%-- Java imports --%>
	<%@ page import="com.google.appengine.api.blobstore.BlobstoreService" %>
	<%@ page import="com.google.appengine.api.blobstore.BlobstoreServiceFactory" %>
	<%@ page import="com.google.appengine.api.blobstore.BlobKey" %>
	<%@ page import="com.google.appengine.api.images.Image" %>
	<%@ page import="com.google.appengine.api.datastore.DatastoreService" %>
	<%@ page import="com.google.appengine.api.datastore.DatastoreServiceFactory" %>
	<%@ page import="com.google.appengine.api.datastore.Entity" %>
	<%@ page import="com.google.appengine.api.datastore.PreparedQuery" %>
	<%@ page import="com.google.appengine.api.datastore.Query" %>

	<%@ page import="com.google.appengine.api.images.ImagesService" %>
	<%@ page import="com.google.appengine.api.images.ImagesServiceFactory" %>


<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>photos</title>
</head>
<body>
<div id="header">
<FORM action="tomain" method="post">
			<input
				type="submit"
				name="button1"
				class="headerbutton"
				value="Main Menu"
				title="">
</FORM>
</div> <!-- header -->
	<% out.println(request.getSession().getAttribute("message")); %>

<%
	
	ImagesService imageService = ImagesServiceFactory.getImagesService();
	DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
	
	Query q = new Query("Photo");
	PreparedQuery pq = datastore.prepare(q);
	
	for (Entity result : pq.asIterable()) {
		//String blobkey = (String) result.getProperty("blobkey");
		
		//BlobKey key = new BlobKey(blobkey);
		BlobKey key = (BlobKey) result.getProperty("blobKey");
		String name = (String) result.getProperty("title");
		String url = imageService.getServingUrl(key,300,false);
		out.println("<img src=\"" + url + "\" />");
		//out.println("<option value=\"" + title + "\"" + selected + ">" + title + "</option>");
	}

 %>
</body>
</html>